/*    */ package system.staros.cblock1;
/*    */ 
/*    */ import java.io.PrintStream;
/*    */ 
/*    */ public class Scheduler
/*    */ {
/*    */   public static final int maxTaskPID = 256;
/* 15 */   private ClassLoader loader = new FileClassLoader();
/*    */   private Task[] tasks;
/*    */ 
/*    */   public Scheduler()
/*    */   {
/* 20 */     this.tasks = new Task[256];
/* 21 */     for (int i = 0; i < 256; i++)
/* 22 */       this.tasks[i] = null;
/*    */   }
/*    */ 
/*    */   public int getFreePID() {
/* 26 */     int i = -1;
/* 27 */     for (int j = 0; j < 256; j++) {
/* 28 */       if (this.tasks[j] == null) {
/* 29 */         i = j;
/* 30 */         break;
/*    */       }
/*    */     }
/* 33 */     return i;
/*    */   }
/*    */ 
/*    */   public void loadClass(String paramString) {
/*    */     try {
/* 38 */       this.loader.loadClass(paramString);
/*    */     }
/*    */     catch (ClassNotFoundException localClassNotFoundException) {
/*    */     }
/*    */   }
/*    */ 
/*    */   public int add(Task paramTask) {
/* 45 */     int i = getFreePID();
/* 46 */     if (i == -1)
/* 47 */       return i;
/* 48 */     paramTask.setPID(i);
/* 49 */     this.tasks[i] = paramTask;
/* 50 */     paramTask.setStarttime(System.currentTimeMillis());
/*    */ 
/* 52 */     return i;
/*    */   }
/*    */ 
/*    */   public int loadTaskClass(String paramString)
/*    */   {
/* 57 */     int i = -1;
/*    */     Class localClass;
/*    */     try {
/* 61 */       localClass = this.loader.loadClass(paramString);
/*    */     } catch (ClassNotFoundException localClassNotFoundException) {
/* 63 */       System.out.println("Scheduler.loadTaskClass(): Can't find class: " + paramString);
/* 64 */       return -1;
/*    */     }
/*    */     Task localTask;
/*    */     try {
/* 68 */       localTask = (Task)localClass.newInstance();
/*    */     } catch (Exception localException) {
/* 70 */       localException.printStackTrace();
/* 71 */       System.out.println("Scheduler.loadTaskClass(): Can't create instance: " + paramString);
/* 72 */       return -1;
/*    */     }
/* 74 */     localTask.setName(paramString);
/* 75 */     i = add(localTask);
/* 76 */     return i;
/*    */   }
/*    */ 
/*    */   public Task getTaskByPID(int paramInt) {
/* 80 */     if ((paramInt >= 0) && (paramInt < 256)) {
/* 81 */       return this.tasks[paramInt];
/*    */     }
/* 83 */     return null;
/*    */   }
/*    */ 
/*    */   public void removeTask(int paramInt)
/*    */   {
/* 88 */     Task localTask = this.tasks[paramInt];
/* 89 */     if (localTask != null)
/* 90 */       localTask.stop();
/* 91 */     this.tasks[paramInt] = null;
/*    */   }
/*    */ }

/* Location:           D:\Марк\!IMPORTANT\staros\archive\version-2.260.zip
 * Qualified Name:     system.staros.cblock1.Scheduler
 * JD-Core Version:    0.6.1
 */